]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
loginManager: Expose systemd’s PreparingForSleep property
authorPhilip Withnall <pwithnall@gnome.org>
Wed, 19 Feb 2025 15:50:10 +0000 (15:50 +0000)
committerMarge Bot <marge-bot@gnome.org>
Mon, 3 Mar 2025 15:15:24 +0000 (15:15 +0000)
This will be used in upcoming commits to save the screen time state just
before the system goes to sleep.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/8185
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3643>

js/misc/loginManager.js

index d928ff0220bb25fd48a9ad7f3b0c12cdff7a0703..191b5334fb2afb45c4c9ea6e77b5809fec32a7a5 100644 (file)
@@ -227,12 +227,29 @@ class LoginManagerSystemd extends Signals.EventEmitter {
         this.emit('prepare-for-sleep', aboutToSuspend);
     }
 
+    /**
+     * Whether the machine is preparing to sleep.
+     *
+     * This is true between paired emissions of `prepare-for-sleep`.
+     *
+     * @type {boolean}
+     */
+    get preparingForSleep() {
+        return this._proxy.PreparingForSleep;
+    }
+
     _sessionRemoved(proxy, sender, [sessionId]) {
         this.emit('session-removed', sessionId);
     }
 }
 
 class LoginManagerDummy extends Signals.EventEmitter  {
+    constructor() {
+        super();
+
+        this._preparingForSleep = false;
+    }
+
     getCurrentUserProxy() {
         // we could return a DummyUser object that fakes whatever callers
         // expect, but just never settling the promise should be safer
@@ -272,10 +289,16 @@ class LoginManagerDummy extends Signals.EventEmitter  {
     }
 
     suspend() {
+        this._preparingForSleep = true;
         this.emit('prepare-for-sleep', true);
+        this._preparingForSleep = false;
         this.emit('prepare-for-sleep', false);
     }
 
+    get preparingForSleep() {
+        return this._preparingForSleep;
+    }
+
     /* eslint-disable-next-line require-await */
     async inhibit() {
         return null;